# Makefile for pci_debug.c (AArch64 cross compile on Ubuntu 20.04)

#CROSS_COMPILE ?= aarch64-linux-gnu-
#CC := $(CROSS_COMPILE)gcc
CC=/home/lc/work/tools/arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-gcc
# 这里需要依赖很多 aarch64的lib库。。直接把arm下边带交叉编译工具链的文件系统放进来就行。

SYSROOT := /home/lc/work/tools/arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu/aarch64-none-linux-gnu/libc
ROOTFS := /home/lc/work/s32g/s32g399a/s32g399a-buildroot/output/
CFLAGS := -Wall -O2 --sysroot=$(SYSROOT)
LDFLAGS := -L$(ROOTFS)/target/lib -L$(ROOTFS)/target/lib64  -L$(ROOTFS)/target/usr/lib -L$(ROOTFS)/target/usr/lib32  \
		   -L$(SYSROOT)/usr/lib64 \
		   -lreadline -lncurses
INCLUDE := -I$(SYSROOT)/usr/include \
           -I$(ROOTFS)/host/aarch64-buildroot-linux-gnu/sysroot/usr/include
SRC := pci_debug.c
TARGET := pci_debug.bin

all: $(TARGET)

$(TARGET): $(SRC)
	$(CC) $(CFLAGS)  $(INCLUDE) -o $@ $^ $(LDFLAGS)    

clean:
	rm -f $(TARGET)




# CC=/home/lc/work/tools/arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-gcc
# SYSROOT=/home/lc/work/tools/arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu/aarch64-none-linux-gnu/libc
# CFLAGS=-Wall -O2 --sysroot=$(SYSROOT)
# LDFLAGS=-L$(SYSROOT)/lib -L$(SYSROOT)/usr/lib \
#         -L/home/lc/work/s32g/s32g399a/s32g399a-buildroot/output/target/usr/lib \
#         -lreadline -lncurses
# INCLUDES=-I$(SYSROOT)/usr/include \
#          -I/home/lc/work/s32g/s32g399a/s32g399a-buildroot/output/host/aarch64-buildroot-linux-gnu/sysroot/usr/include

# pci_debug.bin: pci_debug.c
#     $(CC) $(CFLAGS) $(INCLUDES) -o $@ $< $(LDFLAGS)